package admin;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyMemberUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public MyMemberUpdateServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//request.setCharacterEncoding("euc-kr");
		request.setCharacterEncoding("utf-8");

		try{
			MemberWriting writing = new MemberWriting();
			MemberWritingManager manager = MemberWritingManager.getInstance();
			writing.setMb_no(Integer.parseInt(request.getParameter("mb_no")));
			writing.setMb_pw(request.getParameter("mb_pw"));
			writing.setMb_pw_que(request.getParameter("mb_pw_que"));
			writing.setMb_pw_ans(request.getParameter("mb_pw_ans"));
			writing.setMb_name(request.getParameter("mb_name"));
			writing.setMb_zip(request.getParameter("mb_zip"));
			writing.setMb_addr1(request.getParameter("mb_addr1"));
			writing.setMb_addr2(request.getParameter("mb_addr2"));
			writing.setMb_tel(request.getParameter("mb_tel"));
			writing.setMb_phone(request.getParameter("mb_phone"));
			writing.setMb_email(request.getParameter("mb_email"));
			String mb_mailing = request.getParameter("mb_mailing");
			
			if(mb_mailing == null){
				writing.setMb_mailing("n");
			}else if(mb_mailing.equals("y")){
				writing.setMb_mailing("y");
			}else{
				writing.setMb_mailing("n");
			}
			
			manager.update(writing);
		}catch(Exception e){
			e.printStackTrace();
		}
		RequestDispatcher rd = request.getRequestDispatcher("/Dmyna/myshop/member/memberResult.jsp");
		rd.forward(request, response);

	}
}
